<template>
	<view>
		<scroll-view scroll-y class="page" v-if="dataList.length > 0">
			<view class="cu-card article">
				<view class="cu-item shadow" v-for="(item,index) in dataList" :keywords="index">
					<navigator hover-class="none" :url="'/pages/home/routeDetail?routeId=' + item.routeID+'&routeName='+item.routeName" class="nav-li">
						<view class="bus-no">{{item.routeName}}</view>
						<view class="content">
							<view class="desc">
								<view class="station"><text class="tit">{{item.startName}} - {{item.endName}}</text></view>
								<view>
									<view class='cu-tag bg-white'>
										<view class="medium bg-green oval">首</view>
										<text class="timer margin-lr-xs">{{item.firstTime}}</text>
									</view>
									<view class='cu-tag bg-white'>
										<view class="medium bg-red oval">末</view>
										<text class="timer margin-lr-xs">{{item.lastTime}}</text>
									</view>
									<view class="cu-tag bg-white timer">票价:{{item.price}}元</view>
								</view>
							</view>
						</view>
					</navigator>
				</view>
			</view>
		</scroll-view>
		<view class="body" v-if="dataList.length == 0">
			<view class="container" v-if="isLogin == true">
				<image src="../../static/empty.png" />
				<text class="title">暂无收藏路线</text>
				<text class="title">在路线详情页可以进行收藏</text>
			</view>
			<view class="container" v-if="isLogin == false">
				<image src="../../static/empty.png" />
				<view class="content">暂无数据,请您先 <text @click="login" class="btn">登录</text></view>
			</view>
		</view>
	</view>
</template>

<script>
	import http from '../../common/http.js';
	import {
		mapState,
		mapMutations
	} from 'vuex';

	export default {
		data() {
			return {
				dataList: []
			}
		},
		computed: {
			...mapState(['userInfo','isLogin']),
		},
		onShow(){
			this.initData();
		},
		methods: {
			...mapMutations(['showLoading', 'hideLoading']),
			//获取我的收藏列表
		   initData:function(e){
				let _self = this;
				if (_self.isLogin) {
					_self.showLoading();
					http.get('/app/api/qrcode/getfocus/' + _self.userInfo.openId, function(result) {
						if (result.code == 0 && result.data) {
							_self.dataList = result.data;
							console.log(_self.dataList);
							_self.hideLoading();
						}
					})
				}
			},
			login() {
				uni.navigateTo({
					url: '/pages/login/index'
				});
			}
		}
	}
</script>
<style>
	.page {
		height: 100vh;
	}
	.article{
		margin-top: 10px;
	}
	.uni-media-list-body {
		height: auto;
	}

	.uni-media-list-text-top {
		line-height: 1.6em;
	}

	.search {
		border-radius: 8px;
	}

	.search-form {
		background-color: #FFFFFF;
	}

	.bus-no {
		font-size: 19px;
		font-weight: 600;
		color: var(--black);
		line-height: 55px;
		padding: 0 16px;
	}

	.station {
		padding: 0px 0px 5px;
		font-size: 15px;
	}

	.tit {
		font-size: 13px;
		color: #959595;
	}

	.oval {
		border-radius: 4px;
	}

	.medium {
		font-size: 12px;
		padding: 0px 12px;
		height: 20px;
		line-height: 20px;
	}

	.cu-tag {
		padding: 0px;
	}

	.timer {
		font-size: 13px;
		font-weight: 400;
	}

	.bg-green {
		background-color: #70cc5d;
	}

	.bg-red {
		background-color: #ff7f7f;
	}

	.body {
		background: #FFFFFF;
		height: 100vh;
	}

	.container {
		position: absolute;
		display: table-cell;
		width: 100%;
		height: 200px;
		text-align: center;
		top: 30%;
	}

	.container image {
		width: 80px;
		height: 70px;
	}

	.container .title {
		display: block;
		font-size: 15px;
		width: 100%;
		position: relative;
		font-weight: 500;
		color: #8F8F94;
	}

	.content {
		display: block;
		font-size: 15px;
		width: 100%;
		position: relative;
		font-weight: 500;
		color: #8F8F94;
	}

	.content .btn {
		color: #007AFF;
		padding-left: 5px;
	}
</style>
